package com.blockmeta.bbs.businesslibrary.launch;


import com.blockmeta.bbs.baselibrary.base.app.BaseApp;
import com.blockmeta.bbs.baselibrary.utils.SharedPreferenceUtil;
import com.blockmeta.bbs.baselibrary.utils.gson.GsonUtil;
import com.blockmeta.bbs.businesslibrary.pojo.ContactUSPOJO;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class contactusYMAL implements IBaseYMAL {
    public static ContactUSPOJO sContactUSPOJO;
    @Override
    public Map<String, Object> parser(String content, String env) {
        ContactUSPOJO uspojo = null;
        try {
            uspojo = GsonUtil.buildGson().fromJson(content, ContactUSPOJO.class);
            sContactUSPOJO = uspojo;
            SharedPreferenceUtil.putString(BaseApp.getApp(), "contactusYMAL", content);
        } catch (Exception e) {

        }
        HashMap<String, Object> map = new HashMap<>();
        List<ContactUSPOJO.InformationtagsBean> mapInforTag = new ArrayList<>();
        if (uspojo != null) {
            for (ContactUSPOJO.InformationtagsBean informationtagsBean : uspojo.getInformationtags()) {
                ContactUSPOJO.InformationtagsBean bean = new ContactUSPOJO.InformationtagsBean();
                bean.setKey(informationtagsBean.getKey());
                bean.setName(informationtagsBean.getName());
                bean.setImg(informationtagsBean.getImg());
                mapInforTag.add(bean);
            }
        }
        map.put("contactusYMAL", mapInforTag);
        return map;
    }

    public static ContactUSPOJO getContactUSPOJO(){
        if(sContactUSPOJO != null){
            return sContactUSPOJO;
        }else {
            String navigationYMAL = SharedPreferenceUtil.getString(BaseApp.getApp(), "contactusYMAL", "");
            sContactUSPOJO = GsonUtil.buildGson().fromJson(navigationYMAL, ContactUSPOJO.class);
            return sContactUSPOJO;
        }
    }


}